#!coding=utf-8
import datetime
from weixin.api.common import sedTempMsg
import json

#发货通知
def sendlogisticsmsgtocust(openid,logistics,orderid):
    ordertime=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    msg={
           "touser":openid,
           "template_id":"bcgW5q2rxzhEFyg5RzLYvp2OmLWZlnKUKe3iEvxsXPY",
           "url":"http://www.tiantianhw.cn/mshop/index.html",            
           "data":{
                   "first":{
                        "value":"您的订单已交发货，请注意查收！",
                        "color":"#173177"
                    },
                       "keyword1":{
                            "value":logistics,
                            "color":"#173177"
                        },
                       "keyword2":{
                            "value":orderid,
                            "color":"#173177"
                        },
                        "keyword3":{
                            "value":ordertime,
                            "color":"#173177"
                        },
                    "remark":{
                        "value":"欢迎再次光顾天天惠！",
                        "color":"#173177"
                    }
            }
        }
    encodedjson=json.dumps(msg);
    sedTempMsg(encodedjson);

#下单支付成功消息    
def sendpayinfotocust(openid,orderid,tranid):
    msg={
           "touser":openid,
           "template_id":"_izN2CDVFa5fkXG-vRfEDZ_kWhS9_EBEiyV_NMEiCK4",
           "url":"http://www.tiantianhw.cn/mshop/dingdanxiangqing.html?OPENID="+openid+"&ORDERID="+orderid,            
           "data":{
                   "first":{
                        "value":"您的订单已成功受理，我们正在紧密备货中，请等待收货！",
                        "color":"#173177"
                    },
                       "keyword1":{
                            "value":orderid,
                            "color":"#173177"
                        },
                       "keyword2":{
                            "value":tranid,
                            "color":"#173177"
                        },
                    "remark":{
                        "value":"感谢您对天天惠的支持！",
                        "color":"#173177"
                    }
            }
        }
    encodedjson=json.dumps(msg);
    sedTempMsg(encodedjson);    
    
#充值消息
def sendpaycardinfotocust(openid,paycount):
    ordertime=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    msg={
           "touser":openid,
           "template_id":"mQDqgLtwQxRVIN111G0coqppJ_MOE8IRXZKdQUAo8IQ",
           "url":"http://www.tiantianhw.cn/mshop/index.html",            
           "data":{
                   "first":{
                        "value":"恭喜您充值成功！",
                        "color":"#173177"
                    },
                       "keyword1":{
                            "value":paycount,
                            "color":"#173177"
                        },
                       "keyword2":{
                            "value":ordertime,
                            "color":"#173177"
                        },
                       "keyword3":{
                            "value":"微信支付",
                            "color":"#173177"
                        },
                    "remark":{
                        "value":"感谢您对天天惠的支持！",
                        "color":"#173177"
                    }
            }
        }
    encodedjson=json.dumps(msg);
    sedTempMsg(encodedjson);    
    
# sendpaycardinfotocust("oLu6Swn3Nc5WU_U3dU8ZWiH5ylX4","1000");
